Skip to content

Conversation

@weswigham
Copy link
Member

Fixes #17504

Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one style suggestion.

const err = error(baseTypeNode.expression, Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType));
if (baseConstructorType.flags & TypeFlags.TypeParameter) {
const constraint = getConstraintFromTypeParameter(baseConstructorType);
let elaborated = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of mutating let elaborated = false, I think you can just let ctorReturn = unknownType; and mutate that in the innermost if.

}
}
if (!elaborated) {
addRelatedInfo(err, createDiagnosticForNode(baseConstructorType.symbol.declarations[0], Diagnostics.Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1, symbolToString(baseConstructorType.symbol), typeToString(unknownType)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you swap mutable elaborated for mutable ctorReturn, you can forgo the if and just say typeToString(ctorReturn)

@DanielRosenwasser
Copy link
Member

👍

@weswigham weswigham merged commit eba83f4 into microsoft:master Nov 3, 2018
@weswigham weswigham deleted the not-a-constructor-function-error branch November 3, 2018 00:29
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants